home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 168 / as.doc next >
Text File  |  1988-04-17  |  6KB  |  163 lines

  1. The assembler, AS.TTP, takes as input all files listed on the command
  2. line.  Output is placed in YA.OUT, unless over-ridden by the -o option.
  3. All files after the -l in the command line are treated as libraries; only
  4. unresolved symbols will be added to the load module.  The options to the
  5. assembler include:
  6.  
  7.     -o outfile    output placed in outfile
  8.     -m        a symbol table map is included in the output
  9.     -l lib ...    all files that follow are libraries
  10.     -f listfile    input file names are found in listfile
  11.             (this gets around the 128 byte command line limit)
  12.  
  13. The input is always MJC intermediate code, which is a terse form of
  14. assembly language.  This saves space, makes the assembler/loader quicker, 
  15. and allows one to create "object" modules with a regular text editor.  
  16. The drawback is that it takes more space than typical object code.
  17. Basically, every line maps into one or more 68000 instructions.  
  18. I have listed here all the codes, their 68000 assembler equivalent, 
  19. and a brief comment.  Some notes at the end explain labels, 
  20. strings, and operations (e.g. add, sub, etc).
  21.  
  22. !             comment, everything on the line is ignored
  23.  
  24. : sym            define a text symbol
  25. . sym val        define a bss symbol; val is number of bytes needed
  26. * lbl            define a label (see notes)
  27. $ str            define a string (see notes)
  28. = num            word value in text space
  29. =. sym            address value in text space
  30. =$ str            string address in text space
  31. =+ sym val        address of symbol + value in text space
  32. ? sym            remove the symbol from symbol table (for static)
  33.  
  34. csv            link A6,#stk        set frame and stack pointer
  35. ret            unlk A6;rts        return from function
  36. efn stk                        end of function, stk becomes
  37.                                                  the constant for csv
  38.  
  39. rsv reglst        movem reglist,-(A7)    push active registers
  40. rst regpat        movem (A7)+,reglist    pop active registers
  41. rs[wl] x off        move.[wl] Ax,off(A6)    save register variable
  42. rr[wl] off x        move.[wl] off(A6),Ax    restore register variable
  43.  
  44. cse num lbl        cmpi.l #num,D0        compare for case statements
  45. brc op lbl        bcc lbl            branch on condition (see notes)
  46. jmp lbl            bra lbl            unconditional branch
  47. jsr sym            jsr sym            direct function call
  48. jsi x            jsr (Ax)        indirect function call
  49. trp num            trap #num        trap instruction
  50.  
  51. pop num            adda.l #num,A7        pop stuff off the stack
  52. pd[wl] num        move.[wl] #num,-(A7)    push a value on the stack
  53. pl[bwl] off        move.[bwl] off(A6),-(A7)push a local variable
  54. pha x            move.l Ax,-(A7)        push an address on stack
  55. tad x y            move.l Ax,Dy        transfer Areg to Dreg
  56. tda x y            move.l Dx,Ay        transfer Dreg to Areg
  57. tdd x y            move.l Dx,Dy        transfer Dreg to Dreg
  58.  
  59. ld[wl] num d        move.[wl] #num,Dd    load value
  60. ll[bwl] off d        move.[bwl] off(A6),Dd    load local variable
  61. lg[bwl] sym d        move.[bwl] sym,Dd    load global variable
  62. lx[bwl] a i d        move.[bwl] 0(Aa,Di),Dd    load indexed value    
  63. lo[bwl] a off d        move.[bwl] off(Aa),Dd    load indirect with offset
  64. l$ str a        lea #str,Aa        load string address
  65. lag sym a        lea sym,Aa        load global address
  66. lal off a        lea off(A6),Aa        load local address
  67. lax a i x        lea 0(Aa,Di),Ax        load indexed address
  68. lao a off x        lea off(Aa),Ax        load address of indirect offset
  69.  
  70. ob[bwl] op x y        xxx.[bwl] Dx,Dy        binary operation (see notes)
  71. ou[bwl] op x        xxx.[bwl] Dx        unary operation (see notes)
  72.  
  73. so[bwl] a off d        move.[bwl] Dd,off(Aa)    store indirect with offset
  74. sg[bwl] d sym        move.[bwl] Dd,sym    store global
  75. sl[bwl] d off        move.[bwl] Dd,off(A6)    store local
  76. sx[bwl] a i d        move.[bwl] Dd,0(Aa,Di)    store indexed value
  77.  
  78. ad[bwl] num d        various    opcodes        multiply Dd by num, long result
  79.  
  80. cm[bwl] x y        cmp.[bwl] Dx,Dy        compare two values
  81. cd[bwl] x num        cmpi.[bwl] #num,Dx    immediate data compare
  82. ts[bwl] x        tst.[bwl] Dx        test register against 0
  83.  
  84. ig[bwl] num sym        addi.[bwl] #num,sym    increment global
  85. il[bwl] num off        addi.[bwl] #num,off(A6)    increment local
  86. irl num x        addi.l #num,Ax        increment register var
  87. ii[bwl] num a        addi.[bwl] #num,(Aa)    increment indirect
  88.  
  89. xtb x            ext.w Dx        extend byte to word
  90. xtw x            ext.l Dx        extend word to long
  91. xub x            andi.l #0xFF,Dx        unsigned extend byte to long
  92. xuw x            andi.l #0xFFFF,Dx    unsigned extend word to long
  93.  
  94.  
  95. Notes:
  96.  
  97. Labels and string identifiers are numbers that are re-used for every function.
  98. As labels and strings are used, the assembler keeps track of their use.  
  99. When the "efn" opcode is encountered, all the label forward references
  100. are fixed up and the label identifiers can then be re-used.  Strings are
  101. typically a forward reference, which is fixed up when the string is defined.
  102.  
  103. All the possible C operations are numbered by the compiler.  These numbers 
  104. are matched in the assembler to 68000 opcodes.
  105.  
  106.     1    or
  107.     2    exclusive or
  108.     3    and
  109.  
  110.     4    equal (comparison)
  111.     5    not equal (comparison)
  112.     6    less than (comparison)
  113.     7    greater than (comparison)
  114.     8    less than or equal (comparison)
  115.     9    greater than or equal (comparison)
  116.  
  117.     10    shift left
  118.     11    logical shift right
  119.     12    add
  120.     13    subtract
  121.     14    multiply
  122.     15    divide
  123.     16    mod
  124.  
  125.     17    logical negation
  126.     18    arithmetic negation
  127.     19    bitwise negation (eor #0xFFFFFFFF,reg)
  128.  
  129.     20    unsigned equal (comparison)
  130.     21    unsigned not equal (comparison)
  131.     22    unsigned low  (comparison)
  132.     23    unsigned high (comparison)
  133.     24    unsigned low or same (comparison)
  134.     25    unsigned high or same (comparison)
  135.  
  136.     26    arithmetic shift right (sign bit carried through)
  137.  
  138. If your favorite 68000 opcode does not appear in the above, you can resort
  139. to using the "=" facility to place opcodes in line in the text.  For example,
  140. you can get access to the LineA facilities with:
  141.  
  142. PutPixel(color, x, y) {
  143.     /* set up input LineA variables */
  144.     asm( = 40961 ); /* 40961 == 0xA001 */
  145. }
  146.  
  147. Arguments to opcodes can be set using =. or =$ codes.  For example,
  148.  
  149.     "move.l xxx,yyy" 
  150.  
  151. can be implemented in an intermediate code module as
  152.  
  153. = 9209        # opcode for move.l sym.l,sym.l
  154. =. xxx        # address of symbol xxx
  155. =. yyy        # address of symbol yyy
  156.  
  157. Please remember that all values in the intermediate code are 
  158. (long signed) decimal.  That certainly doesn't make the above easy,
  159. but you should be writing in C most the time anyway, right?
  160.  
  161. I have recently build a filter that takes Motorola assembly format
  162. and generates the stuff above.  Send me a letter if you're interested.
  163.